package com.fr.data.core.db.dml;

import com.fr.base.StringUtils;
import com.fr.base.XMLable;
import com.fr.base.core.ComparatorUtils;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.data.core.db.dialect.Dialect;

public class Table
  implements Fragment, XMLable
{
  public static final String XML_TAG = "Table";
  private String schema;
  private String name;

  public Table()
  {
    this.schema = null;
    this.name = null;
  }

  public Table(String paramString)
  {
    this(null, paramString);
  }

  public Table(String paramString1, String paramString2)
  {
    this.schema = null;
    this.name = null;
    this.schema = paramString1;
    this.name = paramString2;
  }

  public String getSchema()
  {
    return this.schema;
  }

  public void setSchema(String paramString)
  {
    this.schema = paramString;
  }

  public String getName()
  {
    return this.name;
  }

  public void setName(String paramString)
  {
    this.name = paramString;
  }

  public String toNormalSQLString(Dialect paramDialect)
  {
    return paramDialect.table2SQL(this);
  }

  public String toStatementSQLString(Dialect paramDialect)
  {
    return toNormalSQLString(paramDialect);
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    String str = null;
    if ((str = paramXMLableReader.getAttr("schema")) != null)
      this.schema = str;
    if ((str = paramXMLableReader.getAttr("name")) != null)
      this.name = str;
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    paramXMLPrintWriter.startTAG("Table");
    if (getSchema() != null)
      paramXMLPrintWriter.attr("schema", getSchema());
    if (getName() != null)
      paramXMLPrintWriter.attr("name", getName());
    paramXMLPrintWriter.end();
  }

  public String toString()
  {
    if (StringUtils.isBlank(this.name))
      return "";
    StringBuffer localStringBuffer = new StringBuffer();
    if (!(StringUtils.isBlank(this.schema)))
      localStringBuffer.append(this.schema).append(".");
    localStringBuffer.append(this.name);
    return localStringBuffer.toString();
  }

  public boolean equals(Object paramObject)
  {
    if (!(paramObject instanceof Table))
      return false;
    Table localTable = (Table)paramObject;
    return ((ComparatorUtils.equals(this.schema, localTable.schema)) && (ComparatorUtils.equals(this.name, localTable.name)));
  }

  public int hashCode()
  {
    int i = 0;
    i = 37 * i + this.schema.hashCode();
    i = 37 * i + this.name.hashCode();
    return i;
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    return super.clone();
  }
}